﻿// Original author contact info: Owen Emlen (owene_1998@yahoo.com)
// Note: other individuals may also have contributed to this code
// Project hosted on CodePlex.com as of 1/10/2009 at http://www.codeplex.com/EmlenMud
using System.Runtime.Serialization;
using System;
using System.ComponentModel;

namespace BrainTechLLC
{
    [Serializable]
#if NO_SILVERLIGHT
    [Browsable(true)]
    [TypeConverter(typeof(ExpandableObjectConverter))]
#endif
    [DataContract]
    public class SpeedInt : Vector4BaseInt, ISpeedInt, IQuickCopy, IHasSpeedInt
    {
        public SpeedInt() { }
        public SpeedInt(SpeedInt speed) : base(speed) { }

        public ISpeedInt SpeedVector { get { return this; } }
        public bool Moving { get { return (X != 0) || (Y != 0) || (Z != 0); } }

        public int LinearSpeed { get { return Length3D(); } }
        public int SpeedX { get { return X; } set { X = value; } }
        public int SpeedY { get { return Y; } set { Y = value; } }
        public int SpeedZ { get { return Z; } set { Z = value; } }

        public SpeedInt(int x, int y, int z, int w) : base(x, y, z, w) { }
        public SpeedInt(int x, int y, int z) : base(x, y, z) { }

        public object Copy() { return new SpeedInt(X, Y, Z, W); }

        // TODO: this shouldn't modify the passed in SpeedInt object
        public static SpeedInt operator /(SpeedInt speed, int f)
        {
            speed.X /= f;
            speed.Y /= f;
            speed.Z /= f;
            return speed;
        }
    }
}
